package com.iflytek.uoamp.agent.monitor.dump.obj;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class DumpTask {
	private String ip;
	private int task_id;
	private int host_component_id;
	private int task_type;
	private String run_time;
	private int run_stat;
	private String run_command;
	private Date create_time;
	private Date update_time;
	private int finsh_stat;
	private String display_name;
	private long nextRunTime;
	private boolean isUpdate;

	public boolean isUpdate() {
		return isUpdate;
	}

	public void setUpdate(boolean isUpdate) {
		this.isUpdate = isUpdate;
	}

	public long getNextRunTime() {
		return nextRunTime;
	}

	public void setNextRunTime(long nextRunTime) {
		this.nextRunTime = nextRunTime;
	}

	public void setNextRunTime() {
		this.nextRunTime = System.currentTimeMillis() + 1000 * 60L * (long)task_type;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public int getTask_id() {
		return task_id;
	}

	public void setTask_id(int task_id) {
		this.task_id = task_id;
	}

	public int getHost_component_id() {
		return host_component_id;
	}

	public void setHost_component_id(int host_component_id) {
		this.host_component_id = host_component_id;
	}

	public int getTask_type() {
		return task_type;
	}

	public void setTask_type(int task_type) {
		this.task_type = task_type;
	}

	public String getRun_time() {
		return run_time;
	}

	public void setRun_time(String run_time) {
		this.run_time = run_time;
	}

	public int getRun_stat() {
		return run_stat;
	}

	public void setRun_stat(int run_stat) {
		this.run_stat = run_stat;
	}

	public String getRun_command() {
		return run_command;
	}

	public void setRun_command(String run_command) {
		this.run_command = run_command;
	}

	public Date getCreate_time() {
		return create_time;
	}

	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}

	public Date getUpdate_time() {
		return update_time;
	}

	public void setUpdate_time(Date update_time) {
		this.update_time = update_time;
	}

	public int getFinsh_stat() {
		return finsh_stat;
	}

	public void setFinsh_stat(int finsh_stat) {
		this.finsh_stat = finsh_stat;
		this.isUpdate = true;
	}

	public String getDisplay_name() {
		return display_name;
	}

	public void setDisplay_name(String display_name) {
		this.display_name = display_name;
	}

	@Override
	public String toString() {
		return "OSSP_DumpTask [ip=" + ip + ", task_id=" + task_id + ", host_component_id=" + host_component_id + ", task_type=" + task_type + ", run_time=" + run_time + ", run_stat=" + run_stat + ", run_command=" + run_command + ", create_time=" + create_time + ", update_time=" + update_time + ", finsh_stat=" + finsh_stat + ", display_name=" + display_name + "]";
	}

	public Map<String, String> getMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("ip", ip);
		map.put("task_id", task_id + "");
		map.put("host_component_id", host_component_id + "");
		map.put("task_type", task_type + "");
		map.put("run_time", run_time);
		map.put("run_stat", run_stat + "");
		map.put("run_command", run_command);
		map.put("finsh_stat", finsh_stat + "");
		map.put("display_name", display_name);
		return map;
	}

	/**
	 * 给任务对象设置值；
	 * 
	 * @param values
	 */
	public void setValues(Map<String, String> values) {
		this.ip = values.get("ip");
		this.task_id = Integer.parseInt(values.get("task_id"));
		this.host_component_id = Integer.parseInt(values.get("host_component_id"));
		this.task_type = Integer.parseInt(values.get("task_type"));
		this.run_time = values.get("run_time");
		this.run_stat = Integer.parseInt(values.get("run_stat"));
		this.run_command = values.get("run_command");
		this.finsh_stat = Integer.parseInt(values.get("finsh_stat"));
		this.display_name = values.get("display_name");
	}

}